<?php

namespace app\admin\model;
use think\Db;
use think\Model;

class CancelReason extends Model {

    public function __construct() {
        parent::__construct();
    }

    //评价配置列表
    public function getListInfo($page, $limit, $data) {
        $where = [];
        //取消原因
        if (!empty($data['cancel_reason'])) {
            $where['cancel_reason'] = ['like', '%' . rtrim($data['cancel_reason']) . '%'];
        }
        $where['status'] = 1;
        //分页
        $start = ($page - 1) * $limit;
        $count = Db::name('cancel_reason')->where($where)->count();
        $list = Db::name('cancel_reason')->where($where)->limit($start, $limit)->order('id desc')->select();
        foreach ($list as $key=>$value){
            $list[$key]['admin_name'] = getAdminInfo($value['admin_id'],1);
            $list[$key]['add_time']   = date("Y-m-d H:i:s",$value['add_time']);
            $list[$key]['update_admin_name'] = getAdminInfo($value['update_admin_id'],1);
            $list[$key]['update_time']   = !empty($value['update_time'])?date("Y-m-d H:i:s",$value['update_time']):'';
        }
        return array(
            'code' => 0,
            'msg' => '',
            'count' => $count,
            'data' => $list
        );
    }
}
